package com.lyk.dao.impl;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.common.dao.BaseDao;
import com.common.entity.A_transfer;
import com.lyk.dao.A_transferDao;

public class A_transferDaoImpl extends BaseDao<A_transfer> implements A_transferDao {

	@Override
	public List<A_transfer> findByCondition(Map<String, Object> mp) {
		List<Object> paramList=new ArrayList<Object>();
		StringBuffer sf=new StringBuffer();
		sf.append(" select * from a_transfer where 1=1 ");
		if(mp!=null && mp.size()>0){
				if(mp.get("atitle")!=null){
					sf.append("and title like ? ");
					paramList.add(mp.get("atitle"));
				}
		}
		return findBySql(sf.toString(), paramList.toArray());
	}

	@Override
	public int delA_customer(Integer n) {
		String sql = "delete a_transfer where transfer_id = ?";
		return this.executeUpdate(sql, new Object[]{n});
	}
	public A_transfer getEntity(ResultSet rs){
		try {
			A_transfer transfer = new A_transfer();
			transfer.setTransfer_id(rs.getInt("transfer_id"));
			transfer.setTransfer_outid(rs.getInt("transfer_outid"));
			transfer.setAmount_out(rs.getInt("amount_out"));
			transfer.setPoundage(rs.getInt("poundage"));
			transfer.setTransfer_inid(rs.getInt("transfer_inid"));
			transfer.setAmount_in(rs.getInt("amount_in"));
			transfer.setGoods_id(rs.getInt("goods_id"));
			transfer.setTransfer_date(rs.getDate("transfer_date"));
			return transfer;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
